<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>reg</title>
    <link rel="stylesheet" href="css/reg.css">
    <script src="../jquery-3.4.1.js"></script>
    <script src="../Cookie.js"></script>
</head>

<body>
    <div class="wrap reg_wrap">
        <a class="bg_link" id="2014_reg_background_a" target="_blank">&nbsp;</a>
        <h2 class="lg_title">
            <span class="fr">我已经注册，现在就<a href="/sso/login.action" class="blue_link">登录</a></span>Hi，欢迎注册！
        </h2>
        <div class="reg_form reg_form_step1">
            <div class="reg_row ie_myemail">
                <input id="email" name="email" autocomplete="off" placeholder="手机号" class="form-control u_name empty"
                    maxlength="100" type="text">
                <div id="myemail" style="display: none;"></div>
                <i class="i_empty" id="email_empty" style="display: none;">不能为空</i>
                <i class="i_true" id="email_true" style="display: none;"></i> <span id="email_error"
                    style="display: none;"></span>
            </div>
            <div id="capsLock_msg" class="reg_pass_capslock" style="display: none;">
                <i class="capsLock_msg_i"></i>
                <s class="capsLock_msg_s"></s>
                键盘大写锁定已打开，请注意大小写
            </div>
            <div class="reg_row">
                <!-- 密码 -->
                <input type="password" name="user.password" placeholder="登录密码" class="form-control u_ps" id="password"
                    oncopy="return false;" oncut="return false;" onpaste="return false;" maxlength="20">
                <i class="i_empty" style="display: none" id="passport_empty">不能为空</i>
                <span id="password_tip" style="display: none">6-20位字符，建议由字母，数字和符号两种以上组合</span>
                <span id="password_error"></span> <i class="i_true" id="password_true" style="display: none;"></i>
                <div class="box_safety" id="pswdLevel" style="display: none;">
                    <ul>
                        <li>弱</li>
                        <li>中</li>
                        <li>强</li>
                    </ul>
                    安全程度
                </div>
            </div>
            <div class="reg_row psheight">
                <!-- 确认密码 -->
                <input type="password" name="password2" id="password2" placeholder="确认密码"
                    class="form-control u_ps u_ps2" oncopy="return false;" oncut="return false;" onpaste="return false;"
                    maxlength="20"> <i class="i_true" id="password2_true" style="display: none;"></i> <span
                    id="password2_desc"></span>
                <span id="password2_tip" style="display: none">请再次输入登录密码</span><span id="password2_error"></span>
            </div>
            <div class="reg_row verify_box" id="vCodeDiv" style="display: none;">
                <input type="text" class="form-control u_verify" placeholder="验证码" id="validCode" name="validCode"
                    onkeydown="showoff('validCode_desc');" onkeyup="checkCodeKeyUp();" onblur="checkCodeOnBlur();"
                    maxlength="4"> <i class="i_false" id="code_false" style="display: none"></i> <i class="i_true"
                    id="code_true" style="display: none"></i>
                <img align="验证码" class="verifyimg" id="valid_code_pic">
                <a class="verifylink" onclick="return false" href="javascript:void(0);" id="changecode">换一张</a>
                <span id="vcd_desc" class="error"></span>
            </div>
            <div class="reg_row verify_box" id="phoneCodeDiv" style="display: none;">
                <input type="text" style="width:160px" class="form-control u_verify" placeholder="短信验证" id="verifyCode"
                    name="verifyCode" onkeyup="checkPhoneCodeKeyUp();" maxlength="6">

                <i class="i_false" id="verifyCode_false" style="display: none"></i>
                <i class="i_true" id="verifyCode_true" style="display: none"></i>

                <a class="btn_verify" id="btnCode" href="javascript:void(0);">获取短信验证码</a>
                <span id="msgcd_desc" class="error"></span>
            </div>

            <div data-ywpoint="null_null_null_null_I0212_0" class="reg_row">
                <!-- 1药网协议-->
                <label class="checkbox"><span class="two_week">注册即代表您已同意1药网<a class="blue_link"
                            onclick="window.open('//www.111.com.cn/cmsPage/2019f923d1220215103717/index.html','', 'width=600,height=600,scrollbars=1,resizable=yes')"
                            href="javascript:void(0);">《服务协议》</a>和
                        <a class="blue_link"
                            onclick="window.open('//www.111.com.cn/cmsPage/20199f79a4020215104224/index.html','', 'width=600,height=600,scrollbars=1,resizable=yes')"
                            href="javascript:void(0);">《隐私条款》</a>
                    </span></label>
                <button type="button" class="btn btn-primary" id="registerButton">立即注册</button>
            </div>
            <div class="reg_row hz_login">
                <p>使用合作伙伴账号登录：</p>
                <a data-ywpoint="null_null_S0012_null_I0213_0" class="first a_yhd" onclick="jointLogin('YHD');"
                    href="javascript:void(0);">1号店</a>
                <a data-ywpoint="null_null_S0012_null_I0214_1" class="a_zfb" onclick="jointLogin('ZFB')"
                    href="javascript:void(0);">支付宝</a>
                <a data-ywpoint="null_null_S0012_null_I0215_2" class="a_qq" onclick="jointLogin('QQ')"
                    href="javascript:void(0);">QQ</a>
                <a data-ywpoint="null_null_S0012_null_I0216_3" class="a_sina" href="javascript:void(0);"
                    onclick="jointLogin('SINA')">新浪微博</a>
                <a data-ywpoint="null_null_S0012_null_I0217_4" class="a_wlt" onclick="jointLogin('WLT')"
                    href="javascript:void(0);">万里通</a>
                <a data-ywpoint="null_null_S0012_null_I0218_5" class="last a_wy" href="javascript:void(0);"
                    onclick="jointLogin('163')">网易</a>
            </div>
        </div>
    </div>
</body>
<script>
    $(() => {
        //失去焦点时验证用户名是否存在
        $('#email').blur(function () {
            let name = $('#email').val();
            // console.log(name);
            if (name) {//非空判断
                    $.ajax({
                        type: "get",
                        url: "../server/checkname.php",
                        data:{
                            name:name
                        },
                        // dataType: "dataType",
                        success: function (str) {
                            // console.log(str);
                        }
                    });
                // }else{
                //     alert('输入的格式不正确！');
                // }
            }else{
                $("#email_empty").css("display","block");
            }
        })


        //点击注册
        $("#registerButton").click(function () {
            let name = $("#email").val();
            let psw = $("#password").val();
            let psw2 = $("#password2").val();

            if (name && psw && psw2) {
                if (psw2 != psw) {
                    alert('两次输入密码不一致');
                    return false;
                }
                if ((/^1[3-9]\d{9}$/).test(name) && (/^\S{6,20}$/).test(psw)) { //正则判断

                    $.ajax({
                        type: "post",
                        url: "../server/reg.php",
                        data: {
                            name: name,
                            psw: psw
                        },
                        success: function (str) {
                            // console.log(str);
                            location.href = "login.html";
                        }
                    });
                } else {
                    alert('输入的格式不正确！');
                }

            } else {
                $("#email_empty").css("display", "block");
            }
        })
    })
</script>

</html>